using Circus.CodeEditor;

using System;
using System.ComponentModel;
namespace Circus.Syntax.CodeCompletion
{
	public class CodeSnippetCode : ICodeSnippetCode, IComparable
	{
		private string delimiter = SyntaxConsts.DefaultSnippetDelimiter;
		private string kind = string.Empty;
		private string language = string.Empty;
		private string code = string.Empty;
		public virtual string Delimiter
		{
			get
			{
				return this.delimiter;
			}
			set
			{
				if (this.delimiter != value)
				{
					this.delimiter = value;
					this.OnDelimiterChanged();
				}
			}
		}
		public virtual string Kind
		{
			get
			{
				return this.kind;
			}
			set
			{
				if (this.kind != value)
				{
					this.kind = value;
					this.OnKindChanged();
				}
			}
		}
		public virtual string Language
		{
			get
			{
				return this.language;
			}
			set
			{
				if (this.language != value)
				{
					this.language = value;
					this.OnLanguageChanged();
				}
			}
		}
		public virtual string Code
		{
			get
			{
				return this.code;
			}
			set
			{
				if (this.code != value)
				{
					this.code = value;
					this.OnCodeChanged();
				}
			}
		}
	
		protected virtual void OnDelimiterChanged()
		{
		}
		protected virtual void OnKindChanged()
		{
		}
		protected virtual void OnLanguageChanged()
		{
		}
		protected virtual void OnCodeChanged()
		{
		}
		public virtual void Assign(ICodeSnippetCode source)
		{
			this.Delimiter = source.Delimiter;
			this.Kind = source.Kind;
			this.Language = source.Language;
			this.Code = source.Code;
		}
		public virtual int CompareTo(object value)
		{
			if (value is ICodeSnippetCode)
			{
				return string.Compare(this.code, ((ICodeSnippetCode)value).Code, true);
			}
			throw new ArgumentException();
		}
	}
}
